package com.jfinal.weixin.demo.weather;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * Created by wangxiaoyang on 16/8/27.
 */
public class HeWeatherBean {

    public String state = "";
    public NowWeather now ;
    public BaseInfo basic;
    public Suggestion suggestion;

    public String format() {
        StringBuffer buffer = new StringBuffer();
        if( null != basic && null != now ) {
            buffer.append(basic.city+"天气为:\n");
            if( null != now.cond ) {
                buffer.append(now.cond.txt);
                buffer.append(" ");
            }
            buffer.append(now.tmp);
            buffer.append("° ");
            if ( null != now.wind ) {
                buffer.append(now.wind.dir);
                buffer.append(" ");
                buffer.append(now.wind.sc);
                buffer.append("级");
            }
            if( suggestion != null && suggestion.comf != null ) {
                buffer.append("\n舒适指数:");
                buffer.append(suggestion.comf.txt);
            }
            if( suggestion != null && suggestion.drsg != null ) {
                buffer.append("\n穿衣指数:");
                buffer.append(suggestion.drsg.txt);
            }
            if( null != basic.update ) {
                buffer.append("\n更新时间: ");
                buffer.append(basic.update.loc);
            }
        } else {
            buffer.append("查询天气失败!");
        }
        return buffer.toString();
    }

    @Override
    public String toString() {
        return "HeWeatherBean{" +
                "state='" + state + '\'' +
                ", now=" + now +
                '}';
    }

    public static class BaseInfo {
        public String city = "";
        public String cnty = "";
        public String id = "";
        public String lat = "";
        public String lon = "";
        public Update update;
    }

    public static class Update {
        public String loc = "";
        public String utc = "";
    }

    public static class NowWeather {
        public String fl = "";
        public String hum = "";
        public String pcpn = "";
        public String pres = "";
        public String tmp = "";
        public String vis = "";
        public NowCond cond;
        public NowWind wind;

        @Override
        public String toString() {
            return "NowWeather{" +
                    "fl='" + fl + '\'' +
                    ", hum='" + hum + '\'' +
                    ", pcpn='" + pcpn + '\'' +
                    ", pres='" + pres + '\'' +
                    ", tmp='" + tmp + '\'' +
                    ", vis='" + vis + '\'' +
                    ", cond=" + cond +
                    ", wind=" + wind +
                    '}';
        }
    }

    public static class NowCond {
        public String code = "";
        public String txt = "";

        @Override
        public String toString() {
            return "NowCond{" +
                    "code='" + code + '\'' +
                    ", txt='" + txt + '\'' +
                    '}';
        }
    }

    public static class NowWind {
        public String deg = "";
        public String dir = "";
        public String sc = "";
        public String spd = "";

        @Override
        public String toString() {
            return "NowWind{" +
                    "deg='" + deg + '\'' +
                    ", dir='" + dir + '\'' +
                    ", sc='" + sc + '\'' +
                    ", spd='" + spd + '\'' +
                    '}';
        }
    }

    public static class Suggestion {
        public SuggestionItem comf ;
        public SuggestionItem cw ;
        public SuggestionItem drsg ;
        public SuggestionItem flu ;
        public SuggestionItem sport ;
        public SuggestionItem trav ;
        public SuggestionItem uv ;
    }

    public static class SuggestionItem {
        public String brf = "";
        public String txt = "";
    }
}
